package com.web.controller.student;

import com.common.apiresult.CommonResult;
import com.service.serviceInterface.DormService;
import com.service.utils.SecurityUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author liuxuhuang
 * @date 2023年04月04日 10:46
 * @desc 宿舍信息控制器
 */
@RestController
@Api(value = "dormInfo", tags = "宿舍信息控制器")
@RequestMapping(value = "/student/dorm")
@Slf4j
public class DormInfoController {
    @Resource
    private SecurityUtil securityUtil;
    @Resource
    private DormService dormService;

    @GetMapping
    @ApiOperation(value = "获取宿舍信息")
    public CommonResult get() {
        long userId = securityUtil.getUserId(SecurityContextHolder.getContext());
        return CommonResult.success(dormService.getDormInfoAndRoomieInfo(userId));
    }

    @PutMapping
    @ApiOperation(value = "申请换宿")
    public CommonResult addExchangeDorm() {
        return CommonResult.success();
    }
}
